//
//  ThirdView.swift
//  NavigationDemo
//
//  Created by hongyan.yang on 2022/4/15.
//

import SwiftUI

struct ThirdView: View {
    @EnvironmentObject var navigation: Navigation
    @Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>

    @State var forthViewShowing = false
    var body: some View {
        VStack{
            Text("3rd View")
            Button("Pop up a modal view"){
                forthViewShowing = true
            }
            Button("Pop to root view") {
                navigation.secondViewShowing = false
            }
        }
        .fullScreenCover(isPresented: $forthViewShowing) {
            ForthView()
        }//Use fullScreenCover/sheet/alert here
        .navigationToolBar("ThirdView", "back") {
            presentationMode.wrappedValue.dismiss()
        }
    }
}

struct ThirdView_Previews: PreviewProvider {
    static var previews: some View {
        ThirdView()
    }
}

